package com.vb.webpress.data;

public class Constants {
	public static final String DATABASE_NAME = "web_press";
	public static final String DATABASE_ACCOUNT = "root";
	public static final String DATABASE_PASSWORD = "admin";
	
	public interface NewsColum{
		public static final String NEWS_TABLE_NAME = "table_news";

		
		public static final String ID = "_id";
		public static final String TYPE_NAME = "type_name";
		public static final String TIME = "time";
		public static final String PIC_URIS = "pic_uris";
		public static final String TITLE = "title";
		public static final String CONTENT = "content";
		public static final String ATTACHEMENT_URIS = "attachement_uris";
		

		public static final String NEWS_INIT_STATEMENT = "CREATE TABLE IF NOT EXISTS " + NEWS_TABLE_NAME + "(" +
														 ID + " int primary key auto_increment, " + 
														 TYPE_NAME + " text, " + 
														 TIME + " timestamp, " +
														 PIC_URIS + " text, " +
														 TITLE + " text, " +
														 CONTENT + " text, " + 
														 ATTACHEMENT_URIS + " text " + ");"; 
		
		public static final String NEWS_TABLE_INSERT = "INSERT INTO " + NEWS_TABLE_NAME	+ " (" +
													   TYPE_NAME + ", " +
													   TIME + ", " +
													   PIC_URIS + ", " +
													   TITLE + ", " +
													   CONTENT + ", " +
													   ATTACHEMENT_URIS + ") VALUES (?, ?, ?, ?, ?, ?);";
		
		public static final String NEWS_TABLE_FIND_BY_TYPE = "SELECT * FROM " + NEWS_TABLE_NAME + " WHERE " + TYPE_NAME + "=? ORDER BY " + TIME+ " DESC" + " LIMIT ?,?";

		public static final String NEWS_TABLE_FIND_TYPE = "SELECT DISTINCT " + TYPE_NAME + " FROM " + NEWS_TABLE_NAME;
		
		public static final String NEWS_TABLE_FIND_ID = "SELECT * FROM " + NEWS_TABLE_NAME + " WHERE " + ID + "=?";

		public static final String NEWS_TABLE_FIND_ALL_BY_TYPE = "SELECT * FROM " + NewsColum.NEWS_TABLE_NAME + " WHERE " + TYPE_NAME + "=? ORDER BY " + TIME + " DESC";

	}
	
	public interface AccountColum{
		public static final String ACCOUNT_TABLE_NAME = "table_account";
		
		public static final String ID = "account_id";
		public static final String NAME = "account_name";
		public static final String PASSWORD = "account_password";
		public static final String ROLE = "account_role";
		
		public static final String ACCOUNT_INIT_STATEMENT = "CREATE TABLE IF NOT EXISTS " + ACCOUNT_TABLE_NAME + "(" +
															 ID + " int primary key auto_increment, " + 
															 NAME + " varchar(255), " + 
															 PASSWORD + " text, " +
															 ROLE + " text, " + 
															 "CONSTRAINT uc_PersonID UNIQUE (" + ID + ", " + NAME + "));"; 
		public static final String Account_TABLE_FIND_ACCOUNT = "SELECT * FROM " + ACCOUNT_TABLE_NAME + " WHERE " + ID + "=? " + "OR " + NAME + "=?";
		public static final String Account_TABLE_ADD_ACCOUNT = "INSERT INTO " + ACCOUNT_TABLE_NAME	+ " (" +
															   NAME + ", " +
															   PASSWORD + ", " +
															   ROLE + ") VALUES (?, ?, ?);";
		public static final String Account_TABLE_UPDATE_PASSWORD = "UPDATE " + ACCOUNT_TABLE_NAME + " SET " + PASSWORD + "=? WHERE " + ID + "=? OR " + NAME + "=?"; 
	}
	
}
